package ren.kane.asdppp;

import ren.kane.asdppp.transaction.pay.Paycheck;
import ren.kane.asdppp.transaction.pay.PaydayTransaction;
import ren.kane.asdppp.transaction.source.TextParserTransactionSource;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;

/**
 * @author renrk(1275) on 2019-04-21 9:33 PM
 **/
public class Payroll {

    public void parse(String[][] commands) {
        for (String[] command : commands) {
            new TextParserTransactionSource(command).execute();
        }
    }

    public Map<Integer, Double> payFor(LocalDate payDate) {
        PaydayTransaction paydayTransaction = new PaydayTransaction(payDate);
        paydayTransaction.execute();

        Map<Integer, Paycheck> paycheckMap = paydayTransaction.getPaycheckMap();
        Map<Integer, Double> pay = new HashMap<>();
        for (Map.Entry<Integer, Paycheck> entry : paycheckMap.entrySet()) {
            pay.put(entry.getKey(), entry.getValue().getGrossPay());
        }
        return pay;
    }
}
